<?php
// 测试API接口
require_once __DIR__ . '/../vendor/autoload.php';

// 初始化ThinkPHP应用
$app = new \think\App();
$app->initialize();

// 手动加载InitBase行为
$initBase = new \app\common\behavior\InitBase();
$initBase->run();

// 测试数据库连接
try {
    $db = \think\facade\Db::connect();
    echo "数据库连接成功\n";
    
    // 列出所有ob_开头的表
    $tables = $db->query("SHOW TABLES LIKE 'ob_%'");
    echo "找到表：\n";
    foreach ($tables as $table) {
        echo "- " . array_values($table)[0] . "\n";
    }
    
} catch (Exception $e) {
    echo "数据库连接失败：" . $e->getMessage() . "\n";
    exit;
}

// 测试常量是否已定义
if (defined('SYS_DS_PROS')) {
    echo "常量SYS_DS_PROS已定义：" . SYS_DS_PROS . "\n";
} else {
    echo "常量SYS_DS_PROS未定义\n";
}

// 测试System控制器
try {
    // 创建请求对象
    $request = new \think\Request();
    
    // 创建控制器实例
    $controller = new \app\api\controller\System($app, $request);
    
    // 调用方法
    $result = $controller->getSystemConfig();
    
    echo "API调用结果：\n";
    var_dump($result);
    
} catch (Exception $e) {
    echo "API调用失败：" . $e->getMessage() . "\n";
    echo "错误位置：" . $e->getFile() . ":" . $e->getLine() . "\n";
}